# -*- coding: utf-8 -*-
# @File  : test111111.py
# @Author: zbh
# @Date  : 2025/3/31_17:06

import pytest

# Session-level fixture
@pytest.fixture(scope="session")
def session_fixture():
    print("\nInitializing session-level fixture...")
    return "Session Data"

# Module-level fixture
@pytest.fixture(scope="module")
def module_fixture(session_fixture):
    print("\nInitializing module-level fixture...")
    return f"{session_fixture} -> Module Data"

# Class-level fixture
@pytest.fixture(scope="class")
def class_fixture(module_fixture):
    print("\nInitializing class-level fixture...")
    return f"{module_fixture} -> Class Data"

# Function-level fixture
@pytest.fixture(scope="function")
def function_fixture(class_fixture):
    print("\nInitializing function-level fixture...")
    return f"{class_fixture} -> Function Data"

# 测试类
class TestFixtureScopes:
    def test_function_scope_1(self, function_fixture):
        print("Running test_function_scope_1")
        assert function_fixture == "Session Data -> Module Data -> Class Data -> Function Data"

    def test_function_scope_2(self, function_fixture):
        print("Running test_function_scope_2")
        assert function_fixture == "Session Data -> Module Data -> Class Data -> Function Data"

# 其他测试函数
def test_module_scope_1(module_fixture):
    print("\nRunning test_module_scope_1")
    assert module_fixture == "Session Data -> Module Data"

def test_module_scope_2(module_fixture):
    print("\nRunning test_module_scope_2")
    assert module_fixture == "Session Data -> Module Data"









